package com.insight.common.exception;

/**
 * T022: 无效操作异常
 * 当执行不允许的操作时抛出（例如：删除正在采集的数据源、取消已完成的任务）
 */
public class InvalidOperationException extends RuntimeException {

    /**
     * 操作类型
     */
    private final String operation;

    /**
     * 当前状态
     */
    private final String currentState;

    public InvalidOperationException(String operation, String currentState) {
        super(String.format("Cannot %s when state is '%s'", operation, currentState));
        this.operation = operation;
        this.currentState = currentState;
    }

    public InvalidOperationException(String message) {
        super(message);
        this.operation = null;
        this.currentState = null;
    }

    public InvalidOperationException(String operation, String currentState, Throwable cause) {
        super(String.format("Cannot %s when state is '%s'", operation, currentState), cause);
        this.operation = operation;
        this.currentState = currentState;
    }

    public String getOperation() {
        return operation;
    }

    public String getCurrentState() {
        return currentState;
    }
}
